<template>
	<div>
		<div class="g-doc">
    	<header>
    		<span>我的</span>
    	</header>
    	<div class="content">
    		<div class="user_pic"><img src="http://file.test.51bbc.cn/source/admin/api/head_img/20180201/1c86beb9170c1efecebfd5f9096984b6.png" alt="user" width="100%"></div>
    		<div class="user_info">
    			<p class="nickname">{{nickname}}</p>
    			<p class="position">{{position}}</p>
    		</div>
    		<ul class="setting">
    			<li class="user_Info">
    				<div><i class="user_msg"></i><span>用户信息</span></div>
					<div class="rfloat to_right"></div>
				</li>
    			<li>
          <a href="change_password.html">
            <div><i class="cpsw"></i><span>修改密码</span></div>
            <div class="rfloat to_right"></div>
          </a>
				</li>
				<li>
					<a href="setting.html">
						<i class="seeting"></i>
						<span>设置</span>
					</a>
					<div class="rfloat to_right"></div>
				</li>
    			<li class="Logout"  @click="log_out();">
    				<div><i class="logout"></i><span>登出</span></div>
    				<div class="rfloat icon_red">
    				</div>
    			</li>
    		</ul>
		</div>
		<footer>
			<div class="footer_bar clearfix">
				<router-link to="/" class="home"></router-link>
				<router-link to="/order_list" class="dingdan"></router-link>
				<router-link to="/busin_list" class="cheshang"></router-link>
				<router-link to="/me" class="gerens"></router-link>
				<!--<a href="./car_dealer.html" class="cheshang"></a>-->
			</div>
		</footer>
		</div>
		<!--loadding-->
		<div class="loading" :class="{loading_show:l_show}">
			<div class="loading_box">
				<img src="/static/img/0.gif" alt="loading">
			</div></div>
		</div>
	</div>
</template>

<script>
//	import sha1 from '../../static/js/sha/sha1'
//	import common from '../../static/js/common'
	import axios from 'axios'
	//	模拟接口数据
var Mock = require('mockjs');
var data = Mock.mock('me',{
	"code":200,
	"message":"成功！",
	"data":{
		"nickname|1":"nidaye",
		"position|1":"产品经理"
	},
	
})
	export default{
		name:"me",
		data(){
			return{
				nickname:"",
				position:"销售经理",
				l_show:true
			}
		},
		methods:{
			c_title(title){
				document.title = title;
				return this;
			},
			user_msg(){
				var that=this;
				axios.get("me").then(function(res){
					console.log(res);
					var data=res.data;
					if(data.code==200){
						that.nickname=data.data.nickname;
						that.position=data.data.position;
						that.l_show=false;
					}
				})

				return this;
			},
			is_Login(){
			//检查是否登录
			var token=window.localStorage.getItem("token");
			if(!token){
			this.$router.push({
			name:"login",path: '/login'
	});
			}else{
				return false;
			}
			return this;
		},
		log_out(){
			window.localStorage.removeItem('token');
			this.$router.push('/login');
		}
		},
		mounted(){
			this.c_title("我的").user_msg().is_Login();
		}
	}
</script>

<style scoped> 
	@import url("../../static/css/user.css");
	.content{
		margin-top: 1.6rem;
	}
</style>